﻿using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Sprites;
using System.Collections;

public class FoodInfoView : MonoBehaviour
{
    public static FoodInfoView _instance;

    public Text FoodName;
    public Text FoodAttack;
    public Text FoodHealth;
    public Text FoodSpeed;
    public Text FoodRace;
    public Text SkillName;
    public Text SkillDes;
    public Slider Playerhealth;
    public Slider EnemyHealth;

    public Text PlayerHealthNum;
    public Text EnemyHealthNum;

    public Image FoodImage;

    private Food _food;
    private GameObject turnGame;

    void Awake()
    {
        _instance = this;
        this.gameObject.SetActive(false);
        turnGame = GameObject.FindGameObjectWithTag("TurnGame");
    }

    public void  ShowView(Food food)
    {
        _food = food;
        FoodName.text = food.foodInfo.FoodName;
        FoodAttack.text = "攻击 " + food.foodInfo.AttackForce.ToString();
        FoodHealth.text = "生命 " + food.foodInfo.Health.ToString();
        FoodSpeed.text = "速度 " + food.foodInfo.Speed.ToString(); 
        FoodRace.text = food.foodInfo.Race;

        //设置甜咸的颜色
        if (food.foodInfo.Race == "甜党")
            FoodRace.color = Color.red;
        else
            FoodRace.color = Color.blue;

        SkillName.text = food.skillInfo.skillname;
        SkillDes.text = food.skillInfo.des;
        FoodImage.overrideSprite = Resources.Load("Sprite/" + food.foodInfo.SpriteName, typeof(Sprite)) as Sprite;
    }

    public void CloseView() 
    {
        //Debug.Log("CloseView");
        this.gameObject.SetActive(false);
        MapManager._instance.HideRange(_food);
        turnGame.gameObject.SetActive(true);
        MapManager._instance.ShowRange(TeamManager._instance.PlayerFoods[PlayerAttack._instance.MainAttack]);
    }
}
